package VideoPushTool.app;

import VideoPushTool.util.Configs;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Objects;

public class VideoPushTest
{
    public static void main(String[] args) throws Exception
    {
        Configs.init("/test.properties");
        String serverHost = Objects.requireNonNull(Configs.get("Server.address"));

        int serverPort = Configs.getInt("Server.port",10780);
        Socket conn = new Socket(serverHost,serverPort);
        OutputStream os = conn.getOutputStream();

        InputStream fis = VideoPushTest.class.getResourceAsStream("/tcpdump.bin");
        System.out.println(fis);
        int len = -1;
        byte[] block = new byte[512];
        while ((len = fis.read(block)) > -1)
        {
            os.write(block, 0, len);
            os.flush();
            Thread.sleep(20);
            System.out.println("sending...");
        }
        os.close();
        fis.close();
        conn.close();
    }
}